package dal.datastore;

import java.util.ArrayList;

import dto.ColumnDTO;

/**
 * Table object.
 * 
 * @author Stanley
 * 
 */
public class Table {
	private String name;
	private ArrayList<ColumnDTO> columns;

	/**
	 * Constructor
	 * @param name
	 */
	public Table(String name) {
		super();
		this.name = name;
	}

	/**
	 * Constructor
	 * @param name table name
	 * @param columns List columns
	 */
	public Table(String name, ArrayList<ColumnDTO> columns) {
		super();
		this.name = name;
		this.columns = columns;
	}
	/**
	 * Get table name
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * set table name
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Get columns
	 * @return
	 */
	public ArrayList<ColumnDTO> getColumns() {
		return columns;
	}

	/**
	 * Set columns
	 * @param columns ArrayList<ColumnDTO>
	 */
	public void setColumns(ArrayList<ColumnDTO> columns) {
		this.columns = columns;
	}

	@Override
	public String toString() {
		return String.format("(name=%s, columns=%s)", name, columns.toString());
	}

	@Override
	public boolean equals(Object obj) {
		String tblName = ((Table)obj).getName();
		return this.name.equals(tblName);
	}
}
